package duylinh

class UtilsController {

    def utilsService
    def imageService
    def burningImageService


    /*
    Temporary save the uploaded file under /temp in Jackrabbit and response the Path.
     */
    def uploadTempFile =
    {
        log.debug "ENTER uploadTempFile, params=$params"

       // def path = utilsService.tempSaveUpload(request)

        log.debug "END uploadTempFile"
        render path
    }

    def uploadSanPhamAvatar =
    {
        log.debug "ENTER uploadSanPhamAvatar: " + params

        File file = utilsService.tempSaveUploadFS( request )
        def path = file.getPath()

        path = provideImgUrl( file )

        println("END uploadSanPhamAvatar: " + path )

        render path
    }



    def provideImgUrl (File file){
       return utilsService.URL_TO_DUYLINH_FS + "/" +file.getName()
    }
}
